<template>
	<view>
    <button type="default" @click="typeVerify">类型验证（控制台查看）</button>
    <input type="text" v-model="value" placeholder="请输入要验证的字符串" />
    <view class="btns">
      <view class="btn" @click="verify('isPhone')">验证手机号</view>
      <view class="btn" @click="verify('isTel')">验证电话号</view>
      <view class="btn" @click="verify('isEmail')">验证邮箱</view>
      <view class="btn" @click="verify('isDomain')">验证一级域名</view>
      <view class="btn" @click="verify('isUrl')">验证网址</view>
      <view class="btn" @click="verify('isHttp')">验证完整网址</view>
      <view class="btn" @click="verify('isQQ')">验证QQ</view>
      <view class="btn" @click="verify('isWX')">验证微信</view>
      <view class="btn" @click="verify('isBankCode')">验证银行卡</view>
      <view class="btn" @click="verify('isIdCode')">验证身份证</view>
      <view class="btn" @click="verify('isPostCode')">验证邮政编码</view>
      <view class="btn" @click="verify('isIPV4')">验证ipv4</view>
      <view class="btn" @click="verify('isIPV6')">验证ipv6</view>
      <view class="btn" @click="verify('isIP')">验证ip</view>
      <view class="btn" @click="verify('isMoney')">验证金额</view>
      <view class="btn" @click="verify('isDate')">验证日期</view>
      <view class="btn" @click="verify('isInt')">验证整数</view>
      <view class="btn" @click="verify('isFloat')">验证浮点数</view>
      <view class="btn" @click="verify('isNum')">验证数字</view>
      <view class="btn" @click="verify('isLowerLetter')">验证小写字母</view>
      <view class="btn" @click="verify('isUpperLetter')">验证大写字母</view>
      <view class="btn" @click="verify('isLetter')">验证字母</view>
      <view class="btn" @click="verify('isNumberOrLetter')">验证数字或字母</view>
      <view class="btn" @click="verify('isNumberAndLetter')">验证数字加字母</view>
    </view>
    </view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				value: ''
			};
		},
		onLoad() {
			
		},
    
    methods: {
      // 类型验证
      typeVerify() {
        const string = 'asd';
        const number = 123;
        const boolean = true;
        const nullVal = null;
        const undefinedVal = undefined;
        const functionVal = function a() {};
        const array = [1,2,3];
        const object = { a: 1 };
        const symbol = Symbol();
        
        // #ifndef APP-PLUS
        console.clear();
        // #endif
        console.log(array, 'isArray', this.$$t.isArray(array));
        console.log(object, 'isObject', this.$$t.isObject(object));
        console.log(string, 'isString', this.$$t.isString(string));
        console.log(number, 'isNumber', this.$$t.isNumber(number));
        console.log(functionVal, 'isFunction', this.$$t.isFunction(functionVal));
        console.log(boolean, 'isBoolean', this.$$t.isBoolean(boolean));
        console.log(nullVal, 'isNull', this.$$t.isNull(nullVal));
        console.log(undefinedVal, 'isUndefined', this.$$t.isUndefined(undefinedVal));
        console.log(symbol, 'isSymbol', this.$$t.isSymbol(symbol));
        console.log(string, 'isEmptyObject', this.$$t.isEmptyObject(string));
        
        console.log(array, 'isEmptyObject', this.$$t.isEmptyObject(array));
        console.log(object, 'isEmptyObject', this.$$t.isEmptyObject(object));
        console.log({}, 'isEmptyObject', this.$$t.isEmptyObject({}));
        console.log(number, 'isString', this.$$t.isString(number));
        console.log(array, 'isObject', this.$$t.isObject(array));
        console.log(object, 'isArray', this.$$t.isArray(object));
      },
      
      // 数据验证
      verify(type) {
        this.$$t.msg(this.$$t[type](this.value));
      }
    }
	}
</script>

<style lang="scss" scoped>
input{
  padding: 20rpx 24rpx;
  border-bottom: 1px solid #f3f3f3;
}
.btns {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
}
.btn{
  border-radius: 6rpx;
  height: 60rpx;
  padding: 0 30rpx;
  line-height: 60rpx;
  text-align: center;
  margin: 20rpx;
  color: #fff;
  background-color: #4CD964;
  flex-shrink: 0;
}
</style>
